/**
 * Created with JetBrains PhpStorm.
 * User: Artem
 * Date: 18.03.13
 * Time: 17:57
 * To change this template use File | Settings | File Templates.
 */

Ext.define("Pro.view.UpdateOrRemoveEmployee", {
    extend: "Ext.window.Window",
    alias: "widget.updateorremoveemployee",

    layout: "fit",
    height: 300,
    width: 400,
    resizable: false,

    constructor: function(record){
        this.title = localization.UPDATE_OR_REMOVE_EMPLOYEE_TITLE + record.data.name;
        this.employeeRecord = record;
        if (record.data.married){
            this.items[0].items[5].items[0].checked = true;
            this.items[0].items[5].items[1].checked = false;
        } else {
            this.items[0].items[5].items[1].checked = true;
            this.items[0].items[5].items[0].checked = false;
        }
        this.callParent();
    },

    autoShow: true,

    items: [
        {
            xtype: "form",
            bodyPadding: 10,
            id: "updateOrRemoveFormPanel",
            items:[
                {
                    xtype: 'textfield',
                    fieldLabel: localization.UPDATE_OR_REMOVE_EMPLOYEE_FORM_NAME,
                    name: 'name'
                },
                {
                    xtype: 'textfield',
                    name: 'age',
                    fieldLabel: localization.UPDATE_OR_REMOVE_EMPLOYEE_FORM_AGE
                },
                {
                    xtype: 'textfield',
                    name: 'phone',
                    fieldLabel: localization.UPDATE_OR_REMOVE_EMPLOYEE_FORM_PHONE
                },
//                {
//                    xtype: "textfield",
//                    name: "team",
//                    hidden: true
//                },
                {
                    xtype: "combobox",
                    fieldLabel: "Team",
                    editable: false,
                    store: "Teams",
                    queryMode: 'remote',
                    displayField: 'name',
                    name: "team"
                },
                {
                    xtype: "textfield",
                    name: "id",
                    hidden: true
                },
                {
                    xtype: "radiogroup",
                    fieldLabel: localization.UPDATE_OR_REMOVE_EMPLOYEE_FORM_MARRIED || "Married",
                    defaultType: "radiofield",
                    layout: "vbox",
                    items: [
                        {
                            boxLabel: localization.UPDATE_OR_REMOVE_EMPLOYEE_FORM_MARRIED_TRUE || "Married",
                            name: "married",
                            inputValue: true
                        },
                        {
                            boxLabel: localization.UPDATE_OR_REMOVE_EMPLOYEE_FORM_MARRIED_FALSE || "Free",
                            name: "married",
                            inputValue: false
                        }
                    ]
                }
            ]
        }
    ],

    bbar: [
        {
            xtype: "button",
            text: localization.UPDATE_OR_REMOVE_EMPLOYEE_BUTTON_UPDATE,
            id: "update"
        },
        "->",
        {
            xtype: "button",
            text: localization.UPDATE_OR_REMOVE_EMPLOYEE_BUTTON_REMOVE,
            id: "remove"
        }
    ]
});